package com.maila.calltaxi_driver.view;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.maila.calltaxi_driver.R;
import com.maila.calltaxi_driver.data.Order;
import com.zhy.autolayout.utils.AutoUtils;

/**
 *抢单pop
 */

public class PushOrderPop extends PopupWindow  {

    private View mMenuView;
    TextView tv_date,tv_position;
    private ImageView btn_take,btn_recode;
    public PushOrderPop(final Context context, Order order) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.view_push_order, null);
        AutoUtils.autoSize(mMenuView);
        tv_date= (TextView) mMenuView.findViewById(R.id.order_date);
        tv_position= (TextView) mMenuView.findViewById(R.id.order_position);
        btn_take=(ImageView) mMenuView.findViewById(R.id.btn_take_order);
        btn_recode=(ImageView) mMenuView.findViewById(R.id.order_recode);
//        tv_position.setText(order.getPositions());
//        tv_date.setText(order.getStatus());
        btn_recode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        btn_take.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context,"您手慢了,已经被别人抢走了",Toast.LENGTH_SHORT).show();
                dismiss();
            }
        });
        //设置SelectPicPopupWindow的View
        this.setContentView(mMenuView);
//            设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
//            设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        //设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        //设置SelectPicPopupWindow弹出窗体动画效果
        this.setAnimationStyle(R.style.sharepopupanimation);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(80000000);
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);
        //mMenuView添加OnTouchListener监听判断获取触屏位置如果在选择框外面则销毁弹出框
        mMenuView.setOnTouchListener(new View.OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {

                return true;
            }
        });
    }

}
